var doc = getParentDocument();
var parentid = doc.getId(); //父文档ID
//查询条件
var tmbh = doc.getItemValueAsString("tmbh"); //条目编号
var tmzt = doc.getItemValueAsString("tmzt"); //条目主题
var sxxt = doc.getItemValueAsString("sxxt"); //实现系统 
var sxzxt = doc.getItemValueAsString("sxzxt"); //实现子系统 
var jhbb = doc.getItemValueAsString("jhbb"); //计划版本 
var xqbm_fzr = doc.getItemValueAsString("xqbm_fzr"); //需求部门负责人
var sjbm_fzr = doc.getItemValueAsString("sjbm_fzr"); //设计部门负责人
var kfgs_fzr = doc.getItemValueAsString("kfgs_fzr"); //开发公司负责人

//判断当前用户是否央行项目组成员
var flag = false;
var domainid = getDomainid();
var useid = getWebUser().getId();
var user_sql = "select '" + domainid + "' as domainid,ITEM_MEMBER from tlk_employee_belong where ITEM_GROUP = '央行项目群'";
var datas = queryBySQL(user_sql); //获取央行项目组成员
if (datas != null) {
    for (var iter = datas.iterator(); iter.hasNext();) {
        data = iter.next();
        var member = data.getItemValueAsString("MEMBER");
        if (useid.equals(member)) {
            flag = true;
            break;
        }
    }
}

var sql = "select * from tlk_clause_present where parent = '" + parentid + "'";
//var sql = "select s.ITEM_SQDH, s.ITEM_YWMC, c.* from tlk_clause_present c left join tlk_setuo_carryout s on s.id = c.parent where c.parent = '"+getId()+"'";
if (isNotNull(tmbh)) { //条目编号
    sql += " and item_tmbh like '%" + tmbh + "%'";
}
if (isNotNull(tmzt)) { //主题
    sql += " and item_zt like '%" + tmzt + "%'";
}
if (isNotNull(sxxt)) { //实现系统
    if ("空".equals(sxxt)) {
        sql += " and item_xqsxxt =''";
    } else {
        sql += " and item_xqsxxt like '%" + sxxt + "%'";
    }
}
if (isNotNull(sxzxt)) { //实现子系统
    if ("空".equals(sxzxt)) {
        sql += " and item_xqzxt =''";
    } else {
        sql += " and item_xqzxt like '%" + sxzxt + "%'";
    }
}
if (isNotNull(jhbb)) {
    if ("空".equals(jhbb)) {
        sql += " and item_jhsxbb =''";
    } else {
        sql += " and item_jhsxbb like '%" + jhbb + "%'";
    }
}
//--------------------------------
if (isNotNull(xqbm_fzr)) {
    sql += " and item_xqbmfzr like '%" + xqbm_fzr + "%'";
}
if (isNotNull(sjbm_fzr)) {
    sql += " and item_sjbmfzr like '%" + sjbm_fzr + "%'";
}
if (isNotNull(kfgs_fzr)) {
    sql += " and item_gskffzr like '%" + kfgs_fzr + "%'";
}

//是否X行判断

if (!flag) { //是否X行
    sql += " and (item_xmztc <> '是' or ITEM_xmztc is null)";
}

println("获取条目：" + sql);

sql;